package org.onion.pattern.notify.dingtalk.msg;

import lombok.Data;
import lombok.experimental.Accessors;

import java.util.ArrayList;
import java.util.List;

/**
 * 钉钉机器人消息
 */
@Data
@Accessors(chain = true)
public class DingTalkRobotActionCardMsg {

    /**
     * 0-按钮竖直排列，1-按钮横向排列
     * "1" : "0"
     */
    private Boolean btnOrientation;

    private List<Btns> btns;

    /**
     * 0-正常发消息者头像，1-隐藏发消息者头像
     */
    private Boolean hideAvatar;

    private String singleTitle;

    private String singleURL;

    private String text;

    private String title;

    public DingTalkRobotActionCardMsg appendBtns(String title, String actionURL) {
        if (btns == null) {
            this.btns = new ArrayList<>();
        }

        this.btns.add(new Btns().setTitle(title).setActionURL(actionURL));
        return this;
    }

    public DingTalkRobotActionCardMsg appendBtns(String title) {
        if (btns == null) {
            this.btns = new ArrayList<>();
        }

        this.btns.add(new Btns().setTitle(title));
        return this;
    }

    @Data
    @Accessors(chain = true)
    public static class Btns {

        private String actionURL;

        private String title;

    }

}
